package framework;

import java.util.List;

import org.openems.entity.Entity;
import org.openems.entity.Key;

import framework.webclient.EntityQueue;

public class EntityUploader implements Command {
	private EntityQueue socket;
	private Accessor accessor;
	
	public EntityUploader(EntityQueue socket, Accessor accessor) {
		this.socket = socket;
		this.accessor = accessor;
	}

	@Override
	public void execute(List<Key> changedKey, Key key) {
		for (Key k : changedKey) {
			Entity e = accessor.get(k);
			if (e.isPersistable()) {
				this.socket.addEntity(e);
			}
		}
	}

}
